//
//  ChatEmjonView.m
//  BGM
//
//  Created by 我要变好看 on 2019/1/26.
//  Copyright © 2019 com.alirtc.demo. All rights reserved.
//

#import "ChatEmjonView.h"
#import "Common.h"
#import "ChatEmjion.h"

@implementation ChatEmjonView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self != nil) {
        self.backgroundColor = [UIColor whiteColor];
 
        UIScrollView *sc = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, 160)];
        [self addSubview:sc];
        sc.contentSize = CGSizeMake(SCREENW*5, 160);
        
      NSMutableArray *emjoinArray = [[NSMutableArray alloc]init];
      NSString *path = [[NSBundle mainBundle] pathForResource:@"emoji" ofType:@"plist"];
        if (path) {
            NSArray *array = [NSArray arrayWithContentsOfFile:path];
            for (NSDictionary *dict in array)
            {
                 NSArray *emoticons = dict[@"data"];
                for (NSDictionary *emojiDic in emoticons) {
                    ChatEmjion *emoji = [[ChatEmjion alloc]init];
                    emoji.file = [emojiDic objectForKey:@"file"];
                    emoji.emoji_id = [emojiDic objectForKey:@"id"];
                    emoji.tag = [emojiDic objectForKey:@"tag"];
                    emoji.unicode = [emojiDic objectForKey:@"unicode"];
                    NSLog(@"%@",emoji.unicode);
                    [emjoinArray addObject:emoji];
                }
            }
        }
        
        
        ChatEmjion *emoji = [emjoinArray objectAtIndex:0];
        
//        for(int i = 0;i<49;i++){
            UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
        imageV.backgroundColor = [UIColor redColor];
        [imageV setImage:[UIImage imageNamed:emoji.file]];
        [sc addSubview:imageV];
        
//        }
        
        
    }
    return self;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
